package cn.edu.hqu.cst.crj.recyclerdemo2;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.os.Bundle;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {
    private RecyclerView recyclerView;
    private RecyclerAdapter recyclerAdapter;

    private List<String> buttonName;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initData();
        initView();
        setListener();
    }

    private void initData() {
        buttonName = new ArrayList<>(40);
        for(int i=1;i<=40;i++){
            String name="按钮"+i;
            buttonName.add(name);
        }
    }

    private void initView()
    {
        recyclerView = findViewById(R.id.rv_successive_dynasties_huoying);
        // 线性布局管理器
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
        recyclerView.setLayoutManager(linearLayoutManager);
        // 用于描述item的适配器
        recyclerAdapter = new RecyclerAdapter(buttonName);
        recyclerView.setAdapter(recyclerAdapter);
    }

    private void setListener() {
    }
}
